using System;
using BitMango;
using Data;
using UnityEngine;

public static class RewardAd
{
	public static bool IsAdInterstitialReward(string rewardName)
	{
		if (Application.internetReachability == NetworkReachability.NotReachable)
		{
			return false;
		}
		if (!Context.AdManager.IsPossibleToShowVideo())
		{
			DWATTHelper.logEvent("VideoAds", new object[]
			{
				rewardName,
				"RequestFail"
			});
			return false;
		}
		int num = RewardAd.DEFAULT_ADREWARD;
		if (rewardName.Equals("LevelUpReward"))
		{
			num = RewardAd.LEVELUP_ADREWARD;
		}
		else if (rewardName.Equals("PlayScene"))
		{
			num = RewardAd.PLAYSCENE_ADREWARD;
		}
		string @string = PlayerPrefs.GetString(string.Format("{0}_ADREWARD_TIME", rewardName), "NONE");
		int @int = PlayerPrefs.GetInt(string.Format("{0}_ADREWARD_COUNT", rewardName), 0);
		bool flag;
		if (@string.Equals("NONE"))
		{
			PlayerPrefs.SetString(string.Format("{0}_ADREWARD_TIME", rewardName), DateTime.Now.ToString("yyyy/MM/dd"));
			PlayerPrefs.Save();
			flag = true;
		}
		else if ((DateTime.Now - DateTime.Parse(@string)).Days > 0)
		{
			PlayerPrefs.SetString(string.Format("{0}_ADREWARD_TIME", rewardName), DateTime.Now.ToString("yyyy/MM/dd"));
			PlayerPrefs.SetInt(string.Format("{0}_ADREWARD_COUNT", rewardName), 0);
			PlayerPrefs.Save();
			flag = true;
		}
		else
		{
			flag = (@int < num);
		}
		if (flag)
		{
			DWATTHelper.logEvent("VideoAds", new object[]
			{
				rewardName,
				"Show"
			});
		}
		else
		{
			DWATTHelper.logEvent("VideoAds", new object[]
			{
				rewardName,
				"Hide"
			});
		}
		return flag;
	}

	public static void SetRewardCount(string rewardName)
	{
		int num = PlayerPrefs.GetInt(string.Format("{0}_ADREWARD_COUNT", rewardName), 0);
		num++;
		PlayerPrefs.SetInt(string.Format("{0}_ADREWARD_COUNT", rewardName), num);
		PlayerPrefs.Save();
	}

	public static void ShowVideoAds(string rewardName, Action<bool> callback)
	{
		callback(true);
		return;


		if (Application.internetReachability == NetworkReachability.NotReachable)
		{
			if (callback != null)
			{
				callback(false);
			}
		}
		else
		{
			DWATTHelper.logEvent("VideoAds", new object[]
			{
				rewardName,
				"Click"
			});
			Context.AdManager.ShowVideo("rvzone", delegate(bool result)
			{
				UnityEngine.Debug.Log("ShowVideo Callback : " + result);
				if (result)
				{
					DWATTHelper.logEvent("VideoAds", new object[]
					{
						rewardName,
						"Recive",
						DataContainer<Data.Root>.Data.userdata.record.userLevel
					});
					RewardAd.SetRewardCount(rewardName);
					if (callback != null)
					{
						callback(true);
					}
				}
				else
				{
					DWATTHelper.logEvent("VideoAds", new object[]
					{
						rewardName,
						"Fail"
					});
					if (callback != null)
					{
						callback(false);
					}
				}
			}, 0);
		}
	}

	public static int GetRewardCount(string rewardName)
	{
		return PlayerPrefs.GetInt(string.Format("{0}_ADREWARD_COUNT", rewardName), 0);
	}

	public static int GetLimitCount(string rewardName)
	{
		int result = RewardAd.DEFAULT_ADREWARD;
		if (rewardName.Equals("LevelUpReward"))
		{
			result = RewardAd.LEVELUP_ADREWARD;
		}
		else if (rewardName.Equals("PlayScene"))
		{
			result = RewardAd.PLAYSCENE_ADREWARD;
		}
		return result;
	}

	public static int LEVELUP_ADREWARD = 9999;

	public static int DEFAULT_ADREWARD = 9999;

	public static int PLAYSCENE_ADREWARD = 5;
}
